<?php if(!defined('PUBLIC_DIR')) die('No Access!');

Cnamespace('System');
abstract class Error implements iError{
	public static function DebugError($errno, $errstr, $errfile, $errline){
		if (!(error_reporting() & $errno)) {
			return;
		}

		$exit = null;
		$type = '';
		
		switch ($errno) {
			case E_ERROR:
				$type = 'Error';
				$exit = 1;
				break;
			case E_WARNING:
				$type = 'Warning';
				break;
			case E_PARSE:
				$type = 'Parse error';
				break;
			case E_NOTICE:
				$type = 'Notice';
				break;
			case E_USER_ERROR:
				$type = 'User error';
				$exit = 1;
				break;
			case E_USER_WARNING:
				$type = 'User warning';
				break;
			case E_USER_NOTICE:
				$type = 'User notice';
				break;
			default:
				$type = "Unknown error type: [$errno]";
				break;
		}
		echo Markup::generateErrorMarkup($errstr, $type, $errfile, $errline, array(__FUNCTION__));
		
		if($exit !== null && is_int($exit)) exit($exit);
		//var_dump(E_CORE_ERROR);//16
		//var_dump(E_CORE_WARNING);//32
		//var_dump(E_COMPILE_ERROR);//64
		//var_dump(E_COMPILE_WARNING);//128
		return true;
	}

	public static function DebugException($exception){
		echo Markup::generateDebugExceptionMarkup($exception, array(__FUNCTION__));
	}
}